export const getMenuList = (data, parent = {}, list = []) => {
  data.forEach(({ menus, ...item }) => {
    const label = item.label || item.title;
    const name = item.name || label.toLocaleLowerCase().split(/\s+/).join('');
    const newItem = {
      ...item,
      name,
      label,
      type: 'menu'
    };

    newItem.path && _.set(newItem, 'path', `/${parent.pathPrefix}/${newItem.path}`);

    if (menus) {
      newItem.contextRoot = item.contextRoot || parent.contextRoot;
      newItem.pathPrefix = item.pathPrefix || parent.pathPrefix;
      newItem.module = item.module || parent.module;
      newItem.children = getMenuList(menus, newItem);
    }

    list.push(newItem);
  });
  return list;
}
